<?php
namespace app\filters;

use Yii;
use yii\base\ActionFilter;

class TimeFilter extends ActionFilter
{
    private $_startTime;

    public function beforeAction($action){
        $this->_startTime = microtime(true);
        echo "开始时间".$this->_startTime;
        return true;
    }

    public function afterAction($action, $result){
        $time = microtime(true) - $this->_startTime;
        return $result."共用时".$time;
    }
}